// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import vuex from 'vuex'
import App from './App'
import router from './router'
import ElementUI, { Message } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

// import {
// 	setRem
// } from '../static/js/rem';
import axios from 'axios'
import api from './api/api'
import storeConfig from './store/store'
import '../static/css/reset.css'
Vue.use(vuex);
var store = new vuex.Store(storeConfig)
Vue.prototype.$http = axios
Vue.prototype.$api = api
Vue.config.productionTip = false
/**
 *  重写ElementUI的Message
 *  single默认值true，因为项目需求，默认只弹出一个，可以根据实际需要设置
 */
const showMessage = Symbol('showMessage')
class DonMessage {
	success(options, single = true) {
		this[showMessage]('success', options, single)
	}
	warning(options, single = true) {
		this[showMessage]('warning', options, single)
	}
	info(options, single = true) {
		this[showMessage]('info', options, single)
	}
	error(options, single = true) {
		this[showMessage]('error', options, single)
	}

	[showMessage](type, options, single) {
		if (single) {
			// 判断是否已存在Message
			if (document.getElementsByClassName('el-message').length === 0) {
				Message[type](options)
			}
		} else {
			Message[type](options)
		}
	}
}
Vue.use(ElementUI)
Vue.prototype.$message = new DonMessage()
// setRem(document, window)
/* eslint-disable no-new */
Vue.mixin({
  methods:{
    errorImage(e){
      e.target.src = require('../static/img/quesheng.jpg')
    }
  }
})
new Vue({
	el: '#app',
	router,
	store,
	components: {
		App
	},
	template: '<App/>'
})
